package gateway.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;

import org.springframework.web.cors.reactive.CorsWebFilter;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
import org.springframework.web.util.pattern.PathPatternParser;
import sun.misc.ObjectInputFilter;

import java.util.regex.Pattern;

/**
 * 网关的java 配置
 */
//@Configuration
public class CorsConfig {
    /*@Bean
    public CorsWebFilter corsWebFilter(){
        CorsConfiguration config = new CorsConfiguration();
        // 允许所有哦的域
        config.addAllowedOrigin("*");
        // 允许所有的请求方法
        config.addAllowedMethod("*");
        // 允许所有的请求头
        config.addAllowedHeader("*");

        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
        // 应用到所有的路径
        source.registerCorsConfiguration("/**",config);
        return new CorsWebFilter(source);
    }*/
}
